package com.cat.greedyAlgorithm;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/rabbits-in-forest/description/?envType=problem-list-v2&envId=greedy
 * @create 2025/10/3 21:00
 * @since JDK17
 */

public class Solution48 {
    public int numRabbits(int[] answers) {
        Map<Integer, Integer> map = new HashMap<>();
        for (int num : answers) {
            map.merge(num, 1, Integer::sum);
        }
        int ans = 0;
        for (int key : map.keySet()) {
            int val = map.get(key), t = key + 1;
            ans += (val + key) / t;
        }
        return ans;
    }
}
